import request from '@/utils/request'

// 工单基本操作
export function Get(id, args) {
  return request({
    url: `/crm/api/ticket/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function Post(data) {
  return request({
    url: '/crm/api/ticket/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function Put(id, data) {
  return request({
    url: `/crm/api/ticket/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: JSON.stringify(data)
  })
}

export function Delete(id) {
  return request({
    url: `/crm/api/ticket/${id || ''}`,
    method: 'delete'
  })
}

// 工单评论相关操作
export function GetComment(id, args) {
  return request({
    url: `/crm/api/ticket/comment/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function PostComment(data) {
  return request({
    url: '/crm/api/ticket/comment/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function PutComment(id, data) {
  return request({
    url: `/crm/api/ticket/comment/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: JSON.stringify(data)
  })
}

export function DeleteComment(id) {
  return request({
    url: `/crm/api/ticket/comment/${id || ''}`,
    method: 'delete'
  })
}

// 工单状态选项
export function GetStatusOptions() {
  return request({
    url: '/crm/api/ticket/status/options/',
    method: 'get'
  })
}

// 工单统计信息
export function GetStatistics() {
  return request({
    url: '/crm/api/ticket/statistics/',
    method: 'get'
  })
}
